#ifndef __WIZ_DESIGNPATTERN_ITERATOR_HPP__SHANHAOBO_19800429__
#define __WIZ_DESIGNPATTERN_ITERATOR_HPP__SHANHAOBO_19800429__

#include "../../Base/Type/WizBaseType.hpp"

#include "../../Base/Operators/WizBaseOperators.hpp"

namespace Wiz
{
    namespace DesignPattern
    {
        namespace Iterator
        {
            namespace Base
            {
                /// ::Wiz::Void::Type   Begin();
                /// ::Wiz::Void::Type   End();
                /// ::Wiz::Bool::Type   Same(const DerivedT*) const;
                template<class DerivedT, class ContainerT, class ElementT, class BaseT = ::Wiz::Null::Type>
                class Type : public ::Wiz::Operators::EqualityComparable1<DerivedT, BaseT>
                {
                public:
                    Type() : m_ContainerPtr(WIZ_NULLPTR), m_ElementPtr(WIZ_NULLPTR)
                    {}
                    virtual ~Type()
                    {
                        m_ContainerPtr = WIZ_NULLPTR;
                        m_ElementPtr = WIZ_NULLPTR;
                    }
                public:
                    WIZ_INLINE ElementT* operator->()
                    {
                        WIZ_ASSERT(::Wiz::IsValidPtr(m_ContainerPtr));
                        WIZ_ASSERT(::Wiz::IsValidPtr(m_ElementPtr));
                        return m_ElementPtr;
                    }
                    WIZ_INLINE friend ::Wiz::Bool::Type operator==(const DerivedT& X, const DerivedT& Y)
                    {
                        WIZ_ASSERT(::Wiz::IsValidPtr(X.m_ContainerPtr));
                        WIZ_ASSERT(::Wiz::IsValidPtr(Y.m_ContainerPtr));
                        WIZ_ASSERT(X.m_ContainerPtr == Y.m_ContainerPtr);

                        return X.Same(&Y);
                    }
                protected:
                    ContainerT*         m_ContainerPtr;
                    ElementT*           m_ElementPtr;
                }; /// end of class Type
            } /// end of namespace Base
        } /// end of namespace Iterator
    } /// end of namespace DesignPattern
} /// end of namespace Wiz

#endif /*__WIZ_DESIGNPATTERN_ITERATOR_HPP__SHANHAOBO_19800429__*/
